<h2>Reserve Loan</h2>

<div class="errorval"><?php echo validation_errors(); ?>
<?php echo $error; ?></div>
<!-- Loan information -->
<p>Enter valid information into the following fields:</p>
<center>
<!-- Loan information -->
<h2>Loan Information</h2>
<table>
<?php echo form_open('staff/loan_management/reserveLoan/' . $volume->access_id ); ?>
<tr>
	<th align="right" width=30%>Item:</th>
	<td><?php echo $volume->title . ' (' . $volume->access_id . ')'; ?></td>
</tr>
<tr>
	<th align="right">Loaned By:</th>
	<td><?php echo anchor('staff/subscriber_management/viewSubscriber/' . $loan->subscriber_id, $subscriber->first_name . ' ' . $subscriber->last_name); ?></td>
</tr>
<tr>
	<th align="right">Loan Date:</th>
	<td><?php echo $loan->loan_date; ?></td>
</tr>
<tr>
	<th align="right">Due Date:</th>
	<td><?php echo $loan->due_date; ?></td>
</tr>
<tr>
	<th align="right">Reserved By:</th>
	<td>
		<?php
		if ($loan->reserve_subscriber)
		{
			echo anchor('staff/subscriber_management/viewSubscriber/' . $loan->reserve_subscriber, $reserve_subscriber->first_name . ' ' . $reserve_subscriber->last_name);
			echo ' - ' . anchor('staff/loan_management/reserveLoan/' . $loan->access_id . '/none', 'Unreserve Item');
		}
		
		else
			echo 'Item not currently reserved.';
		?>
	</td>
</tr>
</table>
<br/><br/>
<table>
<tr><th colspan="3">Reserve For Subscriber:</th></tr>
<tr>
	<th align="right" width=30%>Subscriber Number:</th>
	<td><?php echo form_input('subscriber_id', set_value('subscriber_id')); ?></td>
	<td width="10%"><?php echo form_button('subscriber_id_search', 'Search');?></td>
</tr>
<tr>
	<th align="right">(or) Last Name:</th>
	<td><?php echo form_input('last_name', set_value('last_name')); ?></td>
	<td width="10%"><?php echo form_button('last_name_search', 'Search');?></td>
</tr>
<tr>
	<td colspan="3">
		<p name="subscriber">Please enter subscriber number or subscriber last name.</p>
	</td>
</tr>
</table>

</center>

<script type="text/javascript">
$(document).ready(function() {
		$("[name=subscriber_id_search]").click( function(){
			$.post('<?php echo site_url('staff/jquery/getSubscriberDetailsForReserveLoan/subscriber_id/' . $volume->access_id); ?>', $("[name=subscriber_id]").serialize(), function(data) {
				$('[name=subscriber]').html(data);
			});
		});
		
		$("[name=last_name_search]").click( function(){
			$.post('<?php echo site_url('staff/jquery/getSubscriberDetailsForReserveLoan/last_name/' . $volume->access_id); ?>', $("[name=last_name]").serialize(), function(data) {
				$('[name=subscriber]').html(data);
			});
		}); 
});
</script>
